package com.openlogic.j.completion;

import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
 * @ClassName: CompletionRequest
 * @Description: 请求参数
 * @author weiyongpeng
 * @date 2025年2月21日 上午9:55:03
 */
@JsonDeserialize(builder = CompletionRequest.Builder.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class CompletionRequest {
	
	@JsonProperty
    private final String data;
	
    @JsonProperty
    private final String id;
    
    @JsonProperty
    private final String operator;
    
    @JsonProperty
    private final CompletionHeader completionHeader;

	public CompletionRequest(Builder builder) {
		this.data = builder.data;
		this.id = builder.id;
		this.operator = builder.operator;
		this.completionHeader = builder.completionHeader;
	}

	public String getData() {
		return data;
	}

	public String getId() {
		return id;
	}

	public String getOperator() {
		return operator;
	}

	public CompletionHeader getCompletionHeader() {
		return completionHeader;
	}

	@Override
	public int hashCode() {
		return Objects.hash(completionHeader, data, id, operator);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CompletionRequest other = (CompletionRequest) obj;
		return Objects.equals(completionHeader, other.completionHeader) && Objects.equals(data, other.data)
				&& Objects.equals(id, other.id) && Objects.equals(operator, other.operator);
	}

	@Override
	public String toString() {
		return "CompletionRequest [data=" + data + ", id=" + id + ", operator=" + operator + ", completionHeader="
				+ completionHeader + "]";
	}
    
	public static Builder builder() {
		return new Builder();
	}
	
	@JsonPOJOBuilder(withPrefix = "")
	@JsonIgnoreProperties(ignoreUnknown = true)
	@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
	public static final class Builder {

		private String data;
		private String id;
		private String operator;
		private CompletionHeader completionHeader;

		private Builder() {
		}

		public Builder from(CompletionRequest request) {
			data(request.data);
			id(request.id);
			operator(request.operator);
			completionHeader(request.completionHeader);
			return this;
		}

		public Builder data(String data) {
			this.data = data;
			return this;
		}

		public Builder id(String id) {
			this.id = id;
			return this;
		}

		public Builder operator(String operator) {
			this.operator = operator;
			return this;
		}

		public Builder completionHeader(CompletionHeader completionHeader) {
			this.completionHeader = completionHeader;
			return this;
		}

		public CompletionRequest build() {
			return new CompletionRequest(this);
		}
	}
}
